

#ifndef __DATASTRUCTURE_LINKLIST_H
#define __DATASTRUCTURE_LINKLIST_H

#include "DataStructure_common.h"

#define LinkList_Create(T)                    LinkList_create(sizeof(T))


//链表节点
typedef struct LinkList_N {
	T data;                                	//数据域
	struct LinkList_N *next;                //指针域，下一个节点地址
} LinkList_N, *LinkList_Node;

//链表对象
typedef struct {
	LinkList_Node head;                	//头指针
	LinkList_Node firstElem;            //首元节点
	LinkList_Node endElem;            	//尾元节点

	int length;                        	//节点数量
	size_t dataSize;                	//数据域大小

} LL, *LinkList;


DataStructure_Warning_Unused
LinkList LinkList_create(size_t dataSize);

DataStructure_Warning_Unused
Status LinkList_isEmpty(LinkList list);

DataStructure_Warning_Unused
int LinkList_length(LinkList list);

DataStructure_Warning_Unused
Status LinkList_add(LinkList list, T e);

DataStructure_Warning_Unused
Status LinkList_header(LinkList list, T e);

DataStructure_Warning_Unused
Status LinList_insert(LinkList list, T e, int index);

DataStructure_Warning_Unused
Status LinkList_connect(LinkList list1, LinkList *list2);

DataStructure_Warning_Unused
Status LinkList_clear(LinkList list);

DataStructure_Warning_Unused
Status LinkList_destroy(LinkList *list);

DataStructure_Warning_Unused
Status LinkList_removeHeader(LinkList list, T buf);

DataStructure_Warning_Unused
Status LinkList_remove(LinkList list, int index, T buf);

DataStructure_Warning_Unused
Status LinkList_replace(LinkList list, T e, int index);

DataStructure_Warning_Unused
int LinkList_equalsFind(LinkList list, T e, char (*equals)(T e, T b));

DataStructure_Warning_Unused
Status LinkList_at(LinkList list, int index, T buf);

DataStructure_Warning_Unused
void LinkList_traversal(LinkList list, void(*look)(T e));

DataStructure_Warning_Unused
Status LinkList_reverse(LinkList *list);

#endif //__DATASTRUCTURE_LINKLIST_H
